package Graph_Generator;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class CapacityGenerator {
	
	public static String GetString() throws IOException 
	{
		BufferedReader stringIn = new BufferedReader (new
			InputStreamReader(System.in));
		return  stringIn.readLine();
	}

	public static int GetInt() throws IOException 
	{
		String aux = GetString();
		return Integer.parseInt(aux);
	}
	
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		
		System.out.println("Enter the BipartiteGraph directory");
//		String inputfilename = GetString();
		String inputfilename = "src/_543cloud_new/relation.txt";
		
		BufferedReader br = new BufferedReader(new FileReader(inputfilename));
		String line;
		HashSet<String> temp = new HashSet<>();
		while((line=br.readLine())!=null){
			String[] curline = line.split(",");
			temp.add(curline[0]);
			temp.add(curline[1]);
		}
		
		System.out.print("\nEnter the output file name: \t\t\t");
		String fileName = GetString() + ".txt";	
		String directory = System.getProperty("user.dir");
		
		System.out.println("Enter the maximum capacity: \t\t");
		int carry = GetInt();
		
		PrintWriter outFile = new  PrintWriter(new FileWriter(new File(directory, fileName)));
		
		Iterator<String> str= temp.iterator(); 
		while(str.hasNext()){
			outFile.println(str.next().trim()+","+String.valueOf((int)(Math.floor(Math.random()*carry))));
		}
		
		System.out.println("\n\nOutput is created at: \t" + directory + "\\" + fileName);
		outFile.close();
		
	}

}
